home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 1.iso / dist / fw_qt.idb / usr / freeware / include / qfiledialog.h.z / qfiledialog.h
C/C++ Source or Header  |  2001-04-12  |  10KB  |  325 lines

  1. /****************************************************************************
  2. ** $Id: qt/src/dialogs/qfiledialog.h   2.3.0   edited 2001-01-26 $
  3. **
  4. ** Definition of QFileDialog class
  5. **
  6. ** Created : 950428
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the dialogs module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QFILEDIALOG_H
  39. #define QFILEDIALOG_H
  40.  
  41. struct QFileDialogPrivate;
  42. class QPushButton;
  43. class QLabel;
  44. class QWidget;
  45. class QFileDialog;
  46. class QTimer;
  47. class QNetworkOperation;
  48. class QFileListView;
  49.  
  50. #ifndef QT_H
  51. #include "qdir.h"
  52. #include "qdialog.h"
  53. #include "qlistbox.h"
  54. #include "qlineedit.h"
  55. #include "qlistview.h"
  56. #include "qurloperator.h"
  57. #include "qurlinfo.h"
  58. #endif // QT_H
  59.  
  60. #ifndef QT_NO_FILEDIALOG
  61.  
  62. class Q_EXPORT QFileIconProvider : public QObject
  63. {
  64.     Q_OBJECT
  65. public:
  66.     QFileIconProvider( QObject * parent = 0, const char* name = 0 );
  67.     virtual const QPixmap * pixmap( const QFileInfo & );
  68.  
  69. private:    // Disabled copy constructor and operator=
  70. #if defined(Q_DISABLE_COPY)
  71.     QFileIconProvider( const QFileIconProvider & );
  72.     QFileIconProvider& operator=( const QFileIconProvider & );
  73. #endif
  74. };
  75.  
  76. class Q_EXPORT QFilePreview
  77. {
  78. public:
  79.     QFilePreview();
  80.     virtual void previewUrl( const QUrl &url ) = 0;
  81.  
  82. };
  83.  
  84. class Q_EXPORT QFileDialog : public QDialog
  85. {
  86.     friend class QFileListBox;
  87.     friend class QFileListView;
  88.  
  89.     Q_OBJECT
  90.     Q_ENUMS( Mode ViewMode PreviewMode )
  91.     // ##### Why are this read-only properties ?
  92.     Q_PROPERTY( QString selectedFile READ selectedFile )
  93.     Q_PROPERTY( QString selectedFilter READ selectedFilter )
  94.     Q_PROPERTY( QStringList selectedFiles READ selectedFiles )
  95.     // #### Should not we be able to set the path ?
  96.     Q_PROPERTY( QString dirPath READ dirPath )
  97.     Q_PROPERTY( bool showHiddenFiles READ showHiddenFiles WRITE setShowHiddenFiles )
  98.     Q_PROPERTY( Mode mode READ mode WRITE setMode )
  99.     Q_PROPERTY( ViewMode viewMode READ viewMode WRITE setViewMode )
  100.     Q_PROPERTY( PreviewMode previewMode READ previewMode WRITE setPreviewMode )
  101.     Q_PROPERTY( bool infoPreview READ isInfoPreviewEnabled WRITE setInfoPreviewEnabled )
  102.     Q_PROPERTY( bool contentsPreview READ isContentsPreviewEnabled WRITE setContentsPreviewEnabled )
  103.  
  104. public:
  105.     QFileDialog( const QString& dirName, const QString& filter = QString::null,
  106.                  QWidget *parent=0, const char *name = 0, bool modal = FALSE );
  107.     QFileDialog( QWidget *parent=0, const char *name = 0, bool modal = FALSE );
  108.     ~QFileDialog();
  109.  
  110.     // recommended static functions
  111.  
  112.     static QString getOpenFileName( const QString &initially = QString::null,
  113.                     const QString &filter = QString::null,
  114.                     QWidget *parent = 0, const char* name = 0 ); // ## merge 3.0
  115.     static QString getOpenFileName( const QString &initially,
  116.                     const QString &filter,
  117.                     QWidget *parent, const char* name, const QString& caption );
  118.     static QString getSaveFileName( const QString &initially = QString::null,
  119.                     const QString &filter = QString::null,
  120.                     QWidget *parent = 0, const char* name = 0);// ## merge 3.0
  121.     static QString getSaveFileName( const QString &initially,
  122.                     const QString &filter,
  123.                     QWidget *parent, const char* name,
  124.                     const QString& caption);
  125.     static QString getExistingDirectory( const QString &dir = QString::null,
  126.                      QWidget *parent = 0,
  127.                      const char* name = 0 );// ## merge 3.0
  128.     static QString getExistingDirectory( const QString &dir,
  129.                      QWidget *parent,
  130.                      const char* name,
  131.                      const QString& caption );
  132.     static QString getExistingDirectory( const QString &dir,
  133.                      QWidget *parent,
  134.                      const char* name,
  135.                      const QString& caption,
  136.                      bool dirOnly );
  137.     static QStringList getOpenFileNames( const QString &filter= QString::null,
  138.                      const QString &dir = QString::null,
  139.                      QWidget *parent = 0,
  140.                      const char* name = 0);// ## merge 3.0
  141.     static QStringList getOpenFileNames( const QString &filter,
  142.                      const QString &dir,
  143.                      QWidget *parent,
  144.                      const char* name,
  145.                      const QString& caption);
  146.  
  147.  
  148.     // other static functions
  149.  
  150.     static void setIconProvider( QFileIconProvider * );
  151.     static QFileIconProvider * iconProvider();
  152.  
  153.     // non-static function for special needs
  154.  
  155.     QString selectedFile() const;
  156.     QString selectedFilter() const;
  157.     void setSelection( const QString &);
  158.  
  159.     void selectAll( bool b );
  160.  
  161.     QStringList selectedFiles() const;
  162.  
  163.     QString dirPath() const;
  164.  
  165.     void setDir( const QDir & );
  166.     const QDir *dir() const;
  167.  
  168.     void setShowHiddenFiles( bool s );
  169.     bool showHiddenFiles() const;
  170.  
  171.     void rereadDir();
  172.     void resortDir();
  173.  
  174.     enum Mode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
  175.     void setMode( Mode );
  176.     Mode mode() const;
  177.  
  178.     enum ViewMode { Detail, List };
  179.     enum PreviewMode { NoPreview, Contents, Info };
  180.     void setViewMode( ViewMode m );
  181.     ViewMode viewMode() const;
  182.     void setPreviewMode( PreviewMode m );
  183.     PreviewMode previewMode() const;
  184.  
  185.     bool eventFilter( QObject *, QEvent * );
  186.  
  187.     bool isInfoPreviewEnabled() const;
  188.     bool isContentsPreviewEnabled() const;
  189.     void setInfoPreviewEnabled( bool );
  190.     void setContentsPreviewEnabled( bool );
  191.  
  192.     void setInfoPreview( QWidget *w, QFilePreview *preview );
  193.     void setContentsPreview( QWidget *w, QFilePreview *preview );
  194.  
  195.     QUrl url() const;
  196.  
  197. public slots:
  198.     void done( int );
  199.     void setDir( const QString& );
  200.     void setUrl( const QUrlOperator &url );
  201.     void setFilter( const QString& );
  202.     void setFilters( const QString& );
  203.     void setFilters( const char ** );
  204.     void setFilters( const QStringList& );
  205.  
  206. protected:
  207.     void resizeEvent( QResizeEvent * );
  208.     void keyPressEvent( QKeyEvent * );
  209.  
  210.     void addWidgets( QLabel *, QWidget *, QPushButton * );
  211.     void addToolButton( QButton *b, bool separator = FALSE );
  212.     void addLeftWidget( QWidget *w );
  213.     void addRightWidget( QWidget *w );
  214.     void addFilter( const QString &filter );
  215.  
  216. signals:
  217.     void fileHighlighted( const QString& );
  218.     void fileSelected( const QString& );
  219.     void dirEntered( const QString& );
  220.  
  221. private slots:
  222.     void detailViewSelectionChanged();
  223.     void listBoxSelectionChanged();
  224.     void changeMode( int );
  225.     void fileNameEditReturnPressed();
  226.     void stopCopy();
  227.     void removeProgressDia();
  228.  
  229.     void fileSelected( int );
  230.     void fileHighlighted( int );
  231.     void dirSelected( int );
  232.     void pathSelected( int );
  233.  
  234.     void updateFileNameEdit( QListViewItem *);
  235.     void selectDirectoryOrFile( QListViewItem * );
  236.     void popupContextMenu( QListViewItem *, const QPoint &, int );
  237.     void popupContextMenu( QListBoxItem *, const QPoint & );
  238.     void updateFileNameEdit( QListBoxItem *);
  239.     void selectDirectoryOrFile( QListBoxItem * );
  240.     void fileNameEditDone();
  241.  
  242.     void okClicked();
  243.     void filterClicked(); // not used
  244.     void cancelClicked();
  245.  
  246.     void cdUpClicked();
  247.     void newFolderClicked();
  248.  
  249.     void fixupNameEdit();
  250.  
  251.     void doMimeTypeLookup();
  252.  
  253.     void updateGeometries();
  254.     void modeButtonsDestroyed();
  255.     void urlStart( QNetworkOperation *op );
  256.     void urlFinished( QNetworkOperation *op );
  257.     void dataTransferProgress( int bytesDone, int bytesTotal, QNetworkOperation * );
  258.     void insertEntry( const QValueList<QUrlInfo> &fi, QNetworkOperation *op );
  259.     void removeEntry( QNetworkOperation * );
  260.     void createdDirectory( const QUrlInfo &info, QNetworkOperation * );
  261.     void itemChanged( QNetworkOperation * );
  262.     void goBack();
  263.  
  264. private:
  265.     enum PopupAction {
  266.         PA_Open = 0,
  267.         PA_Delete,
  268.         PA_Rename,
  269.         PA_SortName,
  270.         PA_SortSize,
  271.         PA_SortType,
  272.         PA_SortDate,
  273.         PA_SortUnsorted,
  274.         PA_Cancel,
  275.         PA_Reload,
  276.         PA_Hidden
  277.     };
  278.  
  279.     void init();
  280.     bool trySetSelection( bool isDir, const QUrlOperator &, bool );
  281.     void deleteFile( const QString &filename );
  282.     void popupContextMenu( const QString &filename, bool withSort,
  283.                            PopupAction &action, const QPoint &p );
  284.  
  285.     QDir reserved; // was cwd
  286.     QString fileName;
  287.  
  288.     QFileDialogPrivate *d;
  289.     QFileListView  *files;
  290.  
  291.     QLineEdit  *nameEdit; // also filter
  292.     QPushButton *okB;
  293.     QPushButton *cancelB;
  294.  
  295. #if defined(_WS_WIN_)
  296.     static QString winGetOpenFileName( const QString &initialSelection,
  297.                        const QString &filter,
  298.                        QString* workingDirectory,
  299.                        QWidget *parent = 0,
  300.                        const char* name = 0,
  301.                        const QString& caption = QString::null);
  302.     static QString winGetSaveFileName( const QString &initialSelection,
  303.                        const QString &filter,
  304.                        QString* workingDirectory,
  305.                        QWidget *parent = 0,
  306.                        const char* name = 0,
  307.                        const QString& caption = QString::null);
  308.     static QStringList winGetOpenFileNames( const QString &filter,
  309.                         QString* workingDirectory,
  310.                         QWidget *parent = 0,
  311.                         const char* name = 0,
  312.                         const QString& caption = QString::null);
  313. #endif
  314.  
  315. private:    // Disabled copy constructor and operator=
  316. #if defined(Q_DISABLE_COPY)
  317.     QFileDialog( const QFileDialog & );
  318.     QFileDialog &operator=( const QFileDialog & );
  319. #endif
  320. };
  321.  
  322. #endif
  323.  
  324. #endif // QFILEDIALOG_H
  325.